/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package org.teacup.eightdays.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import org.teacup.eightdays.model.*;
import org.teacup.eightdays.dao.*;
import org.teacup.eightdays.service.*;
import org.teacup.eightdays.vo.query.*;

/**
 * @author Abner email:521yexu2008(a)163.com
 * @version 1.0
 * @since 1.0
 */

import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

@Repository
public class DeliveryAddressDao extends BaseHibernateDao<DeliveryAddress,java.lang.Long>{

	public Class getEntityClass() {
		return DeliveryAddress.class;
	}
	
	public Page findPage(DeliveryAddressQuery query) {
        StringBuilder sqlBuilder = new StringBuilder("select t from DeliveryAddress t where 1=1 ");
        if(isNotEmpty(query.getDeliveryAddressId())) {
            sqlBuilder.append(" and  t.deliveryAddressId = :deliveryAddressId ");
        }
        if(isNotEmpty(query.getSchoolId())) {
            sqlBuilder.append(" and  t.schoolId = :schoolId ");
        }
        if(isNotEmpty(query.getMemberinfoId())) {
            sqlBuilder.append(" and  t.memberinfoId = :memberinfoId ");
        }
        if(isNotEmpty(query.getName())) {
            sqlBuilder.append(" and  t.name = :name ");
        }
        if(isNotEmpty(query.getMobileNo())) {
            sqlBuilder.append(" and  t.mobileNo = :mobileNo ");
        }
        if(isNotEmpty(query.getAddress())) {
            sqlBuilder.append(" and  t.address = :address ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sqlBuilder.append(" order by :sortColumns ");
        }	
        String sql = sqlBuilder.toString();
		return pageQuery(sql,query);
	}
	

}